﻿using AbstructFactory;
using Microsoft.AspNet.SignalR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using XF.Common.Redis;
using XF.Meeting.Entity.Query;

namespace XF.Meeting.Api.Connections
{
    public class PadNoticeHub : Hub
    {/// <summary>
    /// 登陆
    /// </summary>
    /// <param name="DirverId">roomId</param>
        public void userlogin(string DirverId,string macAddress)
        {


            var contId = RedisCache.Hash_Get<string>(DirverId, macAddress);

            var connectId = Context.ConnectionId;
            if (contId!=connectId)
            {
                RedisCache.Hash_Set(DirverId, macAddress, connectId);
            }
         var list=   RedisCache.Hash_GetAll<string>(DirverId);
            Clients.All.say(macAddress+"上线了");
            getmeetlistasync(new CRoomPadQuery()
            {
                 CRoomID=Convert.ToInt32(DirverId),
                  MacAddress=macAddress
            }).Wait();
        }
        public AbsFactoryTE abs = (AbsFactoryTE)AbsFactory.CreateInterface();
        public async Task getmeetlistasync(CRoomPadQuery query) {

            var service = abs.CreateConferenceRoomInterface(query.CRoomID.ToString(), "");
            var list = await service.GetMeetRoomAndInfoForPad(query);
           var conIds = RedisCache.Hash_GetAll<string>(query.CRoomID.ToString());
            Clients.Clients(conIds).showmeet(list);
        }
       

    }
}